package cn.seaboot.admin.api.web;

import cn.seaboot.openapi.Environment;
import cn.seaboot.openapi.PostmanBuilder;
import cn.seaboot.postman.root.Postman;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author Mr.css
 * @version 2020-10-09 17:55
 */
@Controller
@Tag(name = "OpenAPI")
@RequestMapping("sys/api")
public class OpenAPICtrl {

    @Resource
    private ApplicationContext applicationContext;

    /**
     * 获取系统参数
     *
     * @return list
     */
    @ResponseBody
    @Operation(description = "获取系统开放接口")
    @RequestMapping(value = "doc", method = RequestMethod.GET)
    public Postman api() {
        Environment environment = new Environment();
        environment.setOriginalUrl("http://localhost:8081/sea");

        return PostmanBuilder.create()
                .setEnvironment(environment)
                .setExclusive("cn.seaboot.admin.*.web.page;org.springframework")
                .searchContext(applicationContext)
                .build();
    }
}
